//
//  TypeTwoCell.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/4/11.
//  Copyright © 2017年 金橙云. All rights reserved.
//
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#import "TypeTwoCell.h"

@implementation TypeTwoCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        _dataArr = [NSArray new];
        _typeLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)];
        _typeLab.backgroundColor = [UIColor orangeColor];
        _typeLab.textColor = [UIColor whiteColor];
        _typeLab.text = @"   类型去化";
        _typeLab.font = [UIFont systemFontOfSize:14];
        [self addSubview:_typeLab];

        self.barChart = [[ZFBarChart alloc] initWithFrame:CGRectMake(-40, 30, SCREEN_WIDTH+40, 265)];
        self.barChart.dataSource = self;
        self.barChart.delegate = self;
        self.barChart.isResetAxisLineMaxValue = YES;
        self.barChart.valueType = kValueTypeDecimal;
        self.barChart.numberOfDecimal = 2;
        [self addSubview:self.barChart];
        [self.barChart strokePath];
    }
    return self;
}


#pragma mark - ZFGenericChartDataSource

- (NSArray *)valueArrayInGenericChart:(ZFGenericChart *)chart{
    if (self.dataArr.count!=0) {
        if (self.row==1) {
            return self.dataArr[self.row-1][0];
            
        }else{
            return self.dataArr[self.row-2][0];
            
        }
        
    }
    return 0;

  //  return @[@"123", @"256", @"300", @"283", @"490", @"236"];
}

- (NSArray *)nameArrayInGenericChart:(ZFGenericChart *)chart{
    if (self.dataArr.count!=0) {
        if (self.row==1) {
            return self.dataArr[self.row-1][1];
            
        }else{
            return self.dataArr[self.row-2][1];
            
        }
        
    }
    return 0;

  //  return @[@"一年级", @"二年级", @"三年级", @"四年级", @"五年级", @"六年级"];
}

- (NSArray *)colorArrayInGenericChart:(ZFGenericChart *)chart{
    return @[ZFLvColor];
}

- (CGFloat)axisLineMaxValueInGenericChart:(ZFGenericChart *)chart{
    if (self.dataArr.count!=0) {
        if (self.row==1) {
            NSString *max = self.dataArr[2][0];
            return max.floatValue;
            
        }else{
            NSString *max = self.dataArr[2][1];
            return max.floatValue;
            
        }
     }
    return 100;
}

- (NSUInteger)axisLineSectionCountInGenericChart:(ZFGenericChart *)chart{
    return 10;
}
- (NSArray *)gradientColorArrayInBarChart:(ZFBarChart *)barChart{
    ZFGradientAttribute * gradientAttribute1 = [[ZFGradientAttribute alloc] init];
    gradientAttribute1.colors = @[(id)ZFColor(15, 212, 201, 1).CGColor, (id)ZFWhite.CGColor];
    gradientAttribute1.locations = @[@(0.5), @(0.99)];
    gradientAttribute1.startPoint = CGPointMake(0, 0.5);
    gradientAttribute1.endPoint = CGPointMake(1, 0.5);
    
    return [NSArray arrayWithObjects:gradientAttribute1, nil];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
